<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
  <div id="target1"></div>
</div>
<script>
    description("bug 90391: pointer lock mouse move events then window.open should not crash.")
    window.jsTestIsAsync = true;

    targetdiv1 = document.getElementById("target1");

    todo = [
        function () {
            debug("     Locking targetdiv1.")
            targetdiv1.requestPointerLock();
            document.onpointerlockchange = function () {
                document.onpointerlockchange = null;
                testPassed("document.onpointerlockchange event received.");
                doNextStep();
            };
        },
        function () {
            debug("     Sending mouse move events.")
            var mouseMoveEvents = 0;
            targetdiv1.onmousemove = function () {
                if (++mouseMoveEvents == 2) {
                    targetdiv1.onmousemove = null;
                    doNextStep();
                }
            }
            if (window.eventSender) {
              eventSender.mouseMoveTo(100, 100);
              eventSender.mouseMoveTo(200, 200);
            }
        },
        function () {
            debug("     Calling window.open.")
            gc();
            window.open();
            testPassed("Didn't crash");
            document.exitPointerLock();
            doNextStep();
        },
    ];
    doNextStepWithUserGesture();
</script>
</body>
</html>
